package com.github.mikephil.charting.formatter;

import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.utils.ViewPortHandler;

import java.text.DecimalFormat;

/**
 * Created by sunrx on 2016/2/24.
 */
public class WanFormatter implements ValueFormatter {
    private DecimalFormat mFormat;
    private String mText = "";

    public WanFormatter() {
        mFormat = new DecimalFormat("0.00");
    }

    public WanFormatter(String appendix) {
        this();
        mText = appendix;
    }

    @Override
    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
        return makePretty(value) + mText;
    }

    /**
     * Formats each number properly.
     */
    private String makePretty(double number) {

        String r = mFormat.format(number / 10000f);

//        r = r.replaceAll("E[0-9]", SUFFIX[Character.getNumericValue(r.charAt(r.length() - 1)) / 3]);
//
//        while (r.length() > MAX_LENGTH || r.matches("[0-9]+\\.[a-z]")) {
//            r = r.substring(0, r.length() - 2) + r.substring(r.length() - 1);
//        }

        return r;
    }
}
